<template>
	<div>
		<div class="tabNav">
			<router-link to="/index">
                <img src="../assets/img/sidebar1.png" />首页
            </router-link>
			<b>/<img src="../assets/img/sidebar10.png" />操作日志</b>
		</div>
		<el-row :gutter="24">
			<el-col :span="24">
				<el-card class="cardTits cardTitss cardTitdd invoiceManage table-drop" shadow="hover">
					<div class="search">
						<el-input
						placeholder="企业名称"
						v-model="searchVal"
						></el-input>
						<el-input
							placeholder="用户名称"
							v-model="userName"
						></el-input>
						<el-date-picker
							class="query-select"
							v-model="value1"
							type="datetimerange"
							start-placeholder="开始时间"
							end-placeholder="结束时间"
							range-separator="~">
						</el-date-picker>
						<el-button size="small" style="margin-left: 10px;" type="primary" @click="search()">查询</el-button>
					</div>
					<el-table :data="tableData" stripe style="width: 100%" @sort-change="sortChange">
						<el-table-column width="30">
						</el-table-column>
						<!-- <el-table-column prop="id" sortable="custom" width="100" label="序号">
						</el-table-column> -->
						<el-table-column prop="userName" sortable="custom" label="用户名称">
						</el-table-column>
						<el-table-column prop="businessName" sortable="custom" label="企业名称">
						</el-table-column>
						<el-table-column prop="platformName" sortable="custom" label="平台名称">
						</el-table-column>
						<el-table-column prop="plateMode" sortable="custom" label="平台模式">
							<template #default="item">
								{{ options1[item.row.plateMode] }}
							</template>
						</el-table-column>
						<!-- <el-table-column prop="businessType" sortable="custom" label="客户端类型">
							<template #default="item">
								{{ options2[item.row.businessType] }}
							</template>
						</el-table-column> -->
						<el-table-column prop="content" sortable="custom" label="操作内容">
						</el-table-column>
						<el-table-column prop="method" sortable="custom" label="接口名称">
						</el-table-column>
						<el-table-column prop="loginIp" sortable="custom" label="登录IP">
						</el-table-column>
						<el-table-column prop="loginIpRegion" sortable="custom" label="登录区域">
						</el-table-column>
						<el-table-column prop="createTime" sortable="custom" label="操作时间" width="150">
							<template #default="item">
							<span v-if="item.row.createTime == null">--</span>
							<span v-else>{{ format("yyyy-MM-dd hh:mm:ss", new Date(item.row.createTime)) }}</span>
							</template>
						</el-table-column>
					</el-table>
					<el-pagination v-if="tableData.length > 0" @size-change="handleSizeChange" @current-change="handleCurrentChange"
						:current-page="currentPage" :page-sizes="arrPage" :page-size="selectPage"
						layout="total, sizes, prev, pager, next, jumper" :total="renwuTotals">
					</el-pagination>
				</el-card>
			</el-col>
		</el-row>
	</div>
</template>

<script>
	export default {
		name: "dashboard",
		data() {
			return {
				options1: {
					0: "自然人模式",
					1: "个体户模式",
					3: "无感发薪模式",
				},
				options2: {
					1: "自然人",
					2: "个体户（废弃）",
					3: "企业用户",
					4: "平台端",
					5: "合规云",
					0: "其他",
				},
				userName: "",
				excelDownloadShow: false,
				SelectPlatformData: {}, // 灵活用功平台信息
				orderByZH: false,
				orderByAsc: false,
				orderByColume: 'createTime',
				currentPage: 1,
				renwuTotals: 0, // 结算任务明细总条数
				total: 0, // 总条数
				arrPage: [10, 20], // 每页条数
				selectPage: 10, // 每页选中条数
				tableData: [],
				tableData1: [],
				value: '',
				value1: '',
				searchVal: '',
				rechargeType: '',
				beginTime: '',
				endTime: '',
				serveTime: '',
				auditStatus: {
					0: '待审核'
				},
				id: '',
				busid: ''
			};
		},
		components: {},
		mounted() {
			this.getSelectPlatform()
		},
		computed: {
			role() {
				return this.name === "admin" ? "超级管理员" : "普通用户";
			}
		},

		methods: {
			search(){
				this.getSelectPlatform();
			},
			handleSizeChange(val) {
				this.selectPage = val
				this.getSelectPlatform()
			},
			handleCurrentChange(val) {
				// 切换当前页
				this.currentPage = val
				this.getSelectPlatform()
			},
			getSelectPlatform() {
				// console.log(this.value1)
				if(this.value1){
					this.endTime = (this.value1[1])
					this.beginTime = (this.value1[0])
				}else {
					this.endTime = ''
					this.beginTime = ''
				}
				// 运营端操作日志分页查询
				this.$http({
					url: '/api/quick/log/selectOperateLogPageByBusiness',
					method: 'post',
					headers: {
						'Content-Type': 'application/json'
					},
					data: {
						userName: this.userName,
						beginTime: this.beginTime,
          				endTime: this.endTime,
						businessName: this.searchVal,
						"pageNum": this.currentPage,
						"pageSize": this.selectPage,
						orderByAsc: this.orderByAsc, // 是否正序
						orderByColume: this.orderByColume, // 排序字段
						orderByZH: this.orderByZH, // 是否汉字
					}
				}).then(data => {
					if(data.code === 0) {
						this.tableData = data.result.list
						this.renwuTotals = data.result.total
					}
				})
			},
			
			sortChange(d) {
				// 监听排序
				if(d.prop == null) {
					// 默认排序方式
					this.orderByZH = false
					this.orderByAsc = false
					this.orderByColume = 'createTime'
				}else {
					let orderByZH = false
					if(d.id == "legalName"|| d.id == "receiveBank") {
						orderByZH = true
					}
					this.currentPage = 1
					this.selectPage = 10
					let orderByAsc = d.order == "descending" ? false : true
					this.orderByZH = orderByZH
					this.orderByAsc = orderByAsc
					this.orderByColume = d.id
				}
			},
		}
	};
</script>
<style scoped>
.tabNav strike {
	color: #dd0b01;
    font-weight: bold;
    text-decoration: none;
}
.cardTit {
    color: rgba(10, 46, 106, 1);
    line-height: 50px;
    padding-left: 20px;
    font-size: 14px;
    font-weight: normal;
}
.excelDownload {
    position: absolute;
    right: 30px;
    top: 10px;
    cursor: pointer;
    z-index: 111;
}
.serveTime {
	float: left;
    margin-left: 50px;
    position: relative;
    top: 10px;
}
.showCloro {
	cursor: pointer;
	color: #326CF0;
    text-align: left;
}
</style>
<style>
.cardTitdd .search {
	padding-left: 15px;
}
.cardTitdd .search .el-input {
	width: 260px;
    margin: 16px 10px 20px 10px;
}
.cardTitdd .search .el-input .el-input__inner {
	height: 32px;
    font-size: 12px;
    border-color: #EFF4FA;
}
.cardTitdd .el-range-editor.el-input__inner {
	height: 32px;
    border-color: #eff4fa;
	position: relative;
    top: 5px;
}
.cardTitdd .el-range-editor .el-range-input {
    font-size: 12px;
}
.cardTitdd .el-date-editor .el-range__icon {
	position: relative;
    top: -4px;
}
.cardTitdd .el-date-editor .el-range-separator {
	line-height: 24px;
}
</style>